django model.ForeignKey.on_delete
https://docs.djangoproject.com/en/4.2/ref/models/fields/#django.db.models.ForeignKey.on_delete
The possible values for on_delete are found in django.db.models:
-
CASCADE¶Cascade deletes. Django emulates the behavior of the SQL constraint ON DELETE CASCADE and also deletes the object containing the ForeignKey.
Model.delete()isn’t called on related models, but thepre_deleteandpost_deletesignals are sent for all deleted objects. -
PROTECT¶Prevent deletion of the referenced object by raising
ProtectedError, a subclass ofdjango.db.IntegrityError. -
RESTRICT¶Prevent deletion of the referenced object by raising
RestrictedError(a subclass ofdjango.db.IntegrityError). UnlikePROTECT, deletion of the referenced object is allowed if it also references a different object that is being deleted in the same operation, but via aCASCADErelationship.